<?php

/**
 * This is the model class for table "new_ledger".
 *
 * The followings are the available columns in table 'new_ledger':
 * @property integer $id
 * @property integer $new_ledger_no
 * @property string $branch_of_service
 * @property string $new_ledger_date
 * @property string $new_ledger_quarters_id
 * @property string $new_ledger_updates
 * @property string $new_ledger_update_date
 * @property integer $soldier_id
 * @property integer $employee_id
 *
 * The followings are the available model relations:
 * @property Soldier $soldier
 * @property Employee $employee
 */
class NewLedger extends CActiveRecord
{
const branch_of_service1='PAF';
	const branch_of_service2='PA';
	const branch_of_service3='PN';
	const branch_of_service4='PNM';

	
	
	public function getbranch_of_service(){
		return array(
				self::branch_of_service1=>'PAF',
				self::branch_of_service2=>'PA',
				self::branch_of_service3=>'PN',
				self::branch_of_service4=>'PNM',
					
			);
	}	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return NewLedger the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'new_ledger';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('branch_of_service, soldier_id, employee_id', 'required'),
			array('new_ledger_no, soldier_id, employee_id', 'numerical', 'integerOnly'=>true),
			array('branch_of_service', 'length', 'max'=>10),
			array('new_ledger_date, new_ledger_quarters_id', 'length', 'max'=>45),
			array('new_ledger_updates, new_ledger_update_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, new_ledger_no, branch_of_service, new_ledger_date, new_ledger_quarters_id, new_ledger_updates, new_ledger_update_date, soldier_id, employee_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'soldier' => array(self::BELONGS_TO, 'Soldier', 'soldier_id'),
			'employee' => array(self::BELONGS_TO, 'Employee', 'employee_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'new_ledger_no' => 'New Ledger No',
			'branch_of_service' => 'Branch Of Service',
			'new_ledger_date' => 'New Ledger Date',
			'new_ledger_quarters_id' => 'New Ledger Quarters',
			'new_ledger_updates' => 'New Ledger Updates',
			'new_ledger_update_date' => 'New Ledger Update Date',
			'soldier_id' => 'Soldier',
			'employee_id' => 'Employee',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('new_ledger_no',$this->new_ledger_no);
		$criteria->compare('branch_of_service',$this->branch_of_service,true);
		$criteria->compare('new_ledger_date',$this->new_ledger_date,true);
		$criteria->compare('new_ledger_quarters_id',$this->new_ledger_quarters_id,true);
		$criteria->compare('new_ledger_updates',$this->new_ledger_updates,true);
		$criteria->compare('new_ledger_update_date',$this->new_ledger_update_date,true);
		$criteria->compare('soldier_id',$this->soldier_id);
		$criteria->compare('employee_id',$this->employee_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}